<<<<<<< HEAD
"""
非线性规划
"""

from scipy.optimize import minimize
import numpy as np

# 目标函数


fun = lambda x: x[0]**2 + x[1]**2 + x[2]**2 + 8

cons = ({'type': 'ineq', 'fun': lambda x: x[0]**2 - x[1] + x[2]**2},
        {'type': 'ineq', 'fun': lambda x: -x[0] - x[1]**2 - x[2]**2 + 20},
        {'type': 'eq', 'fun': lambda x: -x[0] - x[1]**2 + 2},
        {'type': 'eq', 'fun': lambda x: x[1] + 2 * (x[2]**2) - 3})

bnds = ((0, None), (0, None), (0, None))

x0 = (0, 0, 0)

res = minimize(fun, x0, method='SLSQP', bounds=bnds, constraints=cons)
print(res)
=======
"""
非线性规划
"""

from scipy.optimize import minimize
import numpy as np

# 目标函数


fun = lambda x: x[0]**2 + x[1]**2 + x[2]**2 + 8

cons = ({'type': 'ineq', 'fun': lambda x: x[0]**2 - x[1] + x[2]**2},
        {'type': 'ineq', 'fun': lambda x: -x[0] - x[1]**2 - x[2]**2 + 20},
        {'type': 'eq', 'fun': lambda x: -x[0] - x[1]**2 + 2},
        {'type': 'eq', 'fun': lambda x: x[1] + 2 * (x[2]**2) - 3})

bnds = ((0, None), (0, None), (0, None))

x0 = (0, 0, 0)

res = minimize(fun, x0, method='SLSQP', bounds=bnds, constraints=cons)
print(res)
>>>>>>> a66c8eec2c3bbe955d7da215f43ffffda9c7b6b5
